<template>
	<view class="image_text_wrapper"> 
		<view class="image_text_item" v-for="(item,index) in list" :key="index" @click="jumpPage(item)">
			<img :src="item.src" :onerror="tabErrorPicture(item)" />
			<text class="word">{{item.text}}</text>
		</view>
	</view>
</template>

<script>
import { URLParams } from '@/utils/util'
export default {
	props:['tuwennav','prevent'],
	data() {
		return {
			list: [],	
			errorPicture: require('@/static/img/default_image.jpg'), 
		}
	},
	created(){
		this.init();		
	},
	methods:{     
		init(){	// 页面初始化
			this.list = this.$props.tuwennav;
			// console.log('list',this.list);
		},	
		tabErrorPicture(v){	// 图片加载失败
			v.src = this.errorPicture;
		},
		jumpPage(v){	// 跳转页面
			let id;		
			if (!v.url) return uni.showToast({ title: '配置参数不完整',icon: 'error' })
			if (v.url.indexOf('product') > -1) {
				id = URLParams(v.url).id;	
				if (!id) return uni.showToast({ title: '配置参数不完整',icon: 'error' })
				uni.navigateTo({ url: `/pages/product/index?id=${id}` })			
			}
			if (v.url.indexOf('livecontent') > -1) {				
				id = URLParams(v.url).id;
				if (!id) return uni.showToast({ title: '配置参数不完整',icon: 'error' })
				uni.navigateTo({ url: `/pages/livecontent/index?id=${id}` })				
			}		 	
		}
	}
}	
</script>

<style lang="scss" scoped>
.image_text_wrapper{
	margin: 10px 0;
	padding: 10px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-top: 1px solid #ebedf0;
	border-bottom: 1px solid #ebedf0;
	overflow: hidden;
	.image_text_item{
		width: 25%;
		text-align: center;
		img{
			display: block;
			width: 25px;
			height: 25px;
			margin: 0 auto 5px;
		}
		.word{
			font-size: 12px;
			color: #646566;
		}
	}
}
</style>